package com.ysd.message.utils;

import java.util.List;

public class ResponeMessageUtil {
	
	/*
	 * 根据layui的接收参数来声明的一个返回数据的工具类
	 */
	
	private Integer code;  	//一般layui接收为0
	private String msg;		//一般为空
	private Integer count;	//查询的数据条数
	private Object data;	//返回的信息内容
	
	
	public Integer getCode() {
		return code;
	}
	public void setCode(Integer code) {
		this.code = code;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public Integer getCount() {
		return count;
	}
	public void setCount(Integer count) {
		this.count = count;
	}
	public Object getData() {
		return data;
	}
	public void setData(Object data) {
		this.data = data;
	}
	
	public ResponeMessageUtil(Integer code, String msg, Integer count, Object data) {
		super();
		this.code = code;
		this.msg = msg;
		this.count = count;
		this.data = data;
	}
	
	public ResponeMessageUtil(Integer code, String msg, Object data) {
		super();
		this.code = code;
		this.msg = msg;
		this.data = data;
	}
	
	
	public ResponeMessageUtil(Object data) {
		super();
		this.data = data;
	}
	public ResponeMessageUtil() {
		super();
	}
	
	
	/**
	 * 用于处理增删改的返回结果是否处理成功，（true/false）
	 * @param count
	 * @return
	 */
	public static Boolean getResMsg(Integer count) {
		if(count > 0) {
			return true;
		}else {
			return false;
		}
	}
	
	/**
	 * 这个为查询所有并且成功后为前台传的数据
	 * @param <T>
	 * @param count 查询数据条数
	 * @param data  查询的所有信息
	 * @return
	 */
	public static <T> ResponeMessageUtil ok(Integer count,List<T> data) {
		if(data.isEmpty()) {
			return new ResponeMessageUtil(0,"",count,null);
		}
		return new ResponeMessageUtil(0,"",count,data);
	}
	
	/**
	 * 用于单个查询出数据显示到前台方便体验
	 * @param data
	 * @return
	 */
	public static ResponeMessageUtil ok(Object data) {
		return new ResponeMessageUtil(data);
	}
	
	/**
	 * 用于上传图片时返回的前台数据
	 * @param msg
	 * @param data
	 * @return
	 */
	 public static ResponeMessageUtil ok(String msg,Object data) { 
		 return new ResponeMessageUtil(0,msg,data); 
	 }
	 
	
	
}
